package acm.广度优先搜索;
import java.util.*;

/**
 * dfs解法
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        while (sc.hasNext()) {
            int n= sc.nextInt();
            int m= sc.nextInt();
            if (n+m==0)return;
            sc.nextLine();
            char[][] maze=new char[n][m];
            for (int i = 0; i < maze.length; i++) {
                maze[i]=sc.nextLine().toCharArray();
            }
            System.out.println(fun2(maze));
        }
    }
    public static byte[][] directions ={
            {-1,-1},    //左上方
            {0,-1},      //上方
            {1,-1},      //右上方
            {-1,0},     //左方
            {0,1},      //右方
            {-1,1},     //左下方
            {1,0},      //下方
            {1,1},      //右下方
    };

    //5 5
//*****
//*@*@*
//*@*@*
//**@**
//*****
    public static int fun2(char[][] maze){
        int res=0;
        for (int i = 0; i < maze.length; i++) {
            for (int j = 0; j < maze[0].length; j++) {
                if (maze[i][j]=='@'){
                    res++;
                    union(i,j,maze);
                }
            }
        }
        return res;
    }
    public static void union(int x,int y,char[][] maze){
        if (x<0||x>=maze.length||y<0||y>=maze[0].length||maze[x][y]=='*'){
            return;
        }
        maze[x][y]='*';
        for (byte[] d : directions) {   //把附近油田熄灭
            union(x+d[0],y+d[1],maze);
        }
    }
}